$(function(){
    $(".confirm").click(function(){
        let users = localStorage.getItem("users");
        let newUser = {
            user: $("#user").val(),
            pass: $("#pass").val()
        }
        if (users) {
            users = JSON.parse(users);
        }else{
            users = [];
        }
        if ($("#pass").val() == $("#check").val()) {
            users.push(newUser);
            localStorage.setItem("users",JSON.stringify(users));
            alert("注册成功");
            location.assign("../html/login.html");
        }else{
            alert("两次密码不相同");
        }
        // 注册功能
    });
    $("#eye").click(function(){
        if ($(this).attr("class").substr(9) == "icon-biyan") {
            $(this).removeClass("icon-biyan").addClass("icon-yanjing");
            $("#pass").prop("type","text");
            $("#check").prop("type","text");
        }else{
            $(this).removeClass("icon-yanjing").addClass("icon-biyan");
            $("#pass").prop("type","password");
            $("#check").prop("type","password");
        }
    });
});